home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / sphigs / sph_dos.lha / dos / srgpdoc / srgp.doc < prev   
Encoding:
Text File  |  1991-11-26  |  38.3 KB  |  936 lines

  1.              SRGP for TURBO C   (v1.0, 23 Aug 90)
  2.  
  3.  
  4. The Simple Raster Graphics Package is composed of a library of functions, and a
  5. header file ("srgp.h") that defines custom data types and constants, and
  6. which prototypes all SRGP routines. This paper is a complete but extremely
  7. terse description of the ANSI-C SRGP binding --- this is not a tutorial. If you
  8. are new to SRGP, you must read Chapter 2 of Computer Graphics --- Principles
  9. and Practice (Foley, van Dam, Feiner, and Hughes, Addison-Wesley, 1990).
  10.  
  11.  
  12.  
  13. 0)    Contrast with Textbook Specification 
  14.  
  15.  
  16.  
  17. 1)    States of the System 
  18.  
  19.  
  20.  
  21. 2)    Canvases 
  22.  
  23.  
  24.  
  25. 3)    Output 
  26.  
  27.        1)   color 
  28.  
  29.        2)   geometric data types
  30.  
  31.        3)   control of the pattern and font tables 
  32.  
  33.        4)   control of attributes affecting output 
  34.  
  35.        5)   generation of primitives 
  36.  
  37.        6)   generation of primitives 
  38.  
  39.  
  40.  
  41. 4)    The copyPixel Procedure 
  42.  
  43.  
  44.  
  45. 5)    Input 
  46.  
  47.        1)   properties of input devices 
  48.  
  49.        2)   input modes 
  50.  
  51.        3)   input devices 
  52.  
  53.        4)   control of attributes 
  54.  
  55.        5)   control of measures 
  56.  
  57.        6)   sample procedures 
  58.  
  59.        7)   event procedures 
  60.  
  61.  
  62.  
  63. 6)    Inquiry
  64.  
  65.  
  66.  
  67. 7)    Control of Table Sizes 
  68.  
  69.  
  70.  
  71. 8)    Debugging and Optimization Aids 
  72.  
  73.  
  74.  
  75. 9)    Miscellaneous  
  76.  
  77.  
  78.  
  79. *************** SECTION 0 >>>> Contrast with Textbook Specification
  80.  
  81. Chapter 3 of the textbook is an academic study of the issues involved in 
  82. implementing any raster graphics package; it is not a description of the actual
  83. internal workings of any particular SRGP implementation. SRGP has been 
  84. implemented on several major types of hardware platforms, and in all cases, 
  85. low-level graphics utilities (QuickDraw on the Mac, X11 on workstations, and
  86. MetaGraphics on the PC) were used. Because the authors of SRGP were not
  87. involved in the implementation of the software actually drawing the primitives,
  88. there is no pixel-level compatibility between SRGP applications running on
  89. different platforms. Fortunately, the inconsistency in appearance (will be
  90. typically noticeable only for extreme values for attributes (very thick
  91. primitives, rare combinations of write mode and pen/fill style, etc.).
  92.  
  93. The textbook's description of locator echo included "no echo" as an option
  94. available to the application. However, a design modification after the book's
  95. publication eliminated that option. There will always be a visible cursor.
  96.  
  97. The PC version currently does NOT support:
  98. **  plane masking
  99. **  XOR write mode for transparent bitmap patterns and text
  100. **  application control of table sizes
  101.  
  102. There are now "deluxe" versions of the measure records for each input device.
  103. These should be used when timestamps and modifier-key chords are needed.
  104.  
  105.  
  106.  
  107. *************** SECTION 1 >>>> States of the System
  108.  
  109. SRGP must be enabled before use, and disabled after use.
  110.  
  111. void SRGP_begin (char *name, int width, int height, int planes,
  112.                  boolean enable_trace);
  113.  
  114.     The window which will represent canvas #0 (the SRGP screen-canvas) is
  115.     created; its size is determined by the values of the second and third
  116.     parameters. The first parameter specifies a name for the application. In
  117.     the X11 and Mac versions, this parameter specifies the name displayed in
  118.     the window; with the PC, it is ignored. The fifth parameter specifies the
  119.     initial status of the tracing feature, which is described later in this
  120.     section.
  121.  
  122.     With the PC version, the two constants SCREEN_WIDTH and SCREEN_HEIGHT may
  123.     be used to specify that canvas 0 should be the size of the screen. If
  124.     a width and height smaller than the screen size are specified, the lower
  125.     lefthand corner of canvas 0 is placed in the lower lefthand corner of the
  126.     screen and all input/output take place in the canvas. (Primitives are
  127.     clipped, and the locator's movement is limited to the canvas.) If the
  128.     width or height is larger than the screen size, again the lower lefthand
  129.     corner of the canvas is placed in the lower lefthand corner of the screen,
  130.     and only those portions of the canvas that fit on the screen are shown.
  131.     Note: the locator's echo is initially placed in the center of the canvas;
  132.     if your canvas 0 is significantly larger than the screen, the locator echo
  133.     may be initially placed off-screen. (Moving the locator toward the lower
  134.     lefthand corner of the screen will bring the locator echo back on-screen.)
  135.  
  136.     The fourth parameter, which specifies the number of color planes the
  137.     application desires, is also ignored in the PC version. The application
  138.     is automatically alloted all the planes.
  139. ------------------------------------------------------------------------------
  140. void SRGP_tracing (boolean);
  141.  
  142.     When tracing is enabled, a message is sent to a logging file ("logfile"
  143.     in the current directory) each time the application calls an SRGP function;
  144.     the message includes echoing of key parameters. IMPORTANT: Calls to some of
  145.     the input functions are NOT traced; see section 5 for details. See section
  146.     7 for more information on execution with tracing.
  147.  
  148.     The initial status of tracing is set when the application calls SRGP_begin,
  149.     but it may be changed at any time via a call to SRGP_tracing.
  150. ------------------------------------------------------------------------------
  151. void SRGP_allowResize (boolean);
  152.  
  153.     In the PC version, this routine does nothing; it is there for
  154.     compatibility with the Mac and X11 versions.
  155. ------------------------------------------------------------------------------
  156. typedef int (*funcptr)();
  157. void SRGP_registerResizeCallback (funcptr);
  158.  
  159.     In the PC version, this routine does nothing; it is there for
  160.     compatibility with the Mac and X11 versions.
  161. ------------------------------------------------------------------------------
  162. void SRGP_end (void);
  163.  
  164.     The screen-canvas window is deleted, and the logging file is closed.
  165.     In the PC version, calling this before terminating is absolutely mandatory!
  166. ------------------------------------------------------------------------------
  167. void SRGP_setVideoMode (int mode);
  168.  
  169.     Allows you to specify the brand/model of monitor you are using, to override
  170.     SRGP's extremely accurate determination thereof.  Overriding is sometimes
  171.     useful; for instance, you may wish to degrade the quality of the output
  172.     in order to gain a speed advantage.  As the parameter, send one of the
  173.     constants defined in the bottom half of "SRGP_SPH.H".
  174.  
  175.  
  176.  
  177. *************** SECTION 2 >>>> Canvases
  178.  
  179. SRGP procedures operate on canvases, a canvas being a 2D array of pixels (a
  180. virtual frame-buffer), whose depth is the number of planes requested by the
  181. application (via the fourth parameter to SRGP_begin).
  182.  
  183. Each canvas has its own local coordinate system. The origin (0,0) for the local
  184. coordinate system is the lower-left corner of the canvas, with the X-coordinate
  185. increasing to the right, and the Y-coordinate increasing towards the top. The
  186. coordinates passed to all primitive-generation procedures are in terms of the
  187. local coordinate system of the currently-active canvas.
  188.  
  189. At any given time, one canvas is active: it is the canvas being modified.
  190. Associated with each canvas is a group of attributes which affect all drawing
  191. into that canvas. Modification of these attributes is only possible when the
  192. corresponding canvas is currently active. When a canvas is created, its
  193. attribute group is initialized to standard default values.
  194.  
  195. Each canvas is identified by a unique integer canvas index. When SRGP is
  196. enabled, one canvas already exists and is active: the screen canvas, having
  197. index 0, whose height and width are determined from the parameters to SRGP_
  198. begin. The screen canvas is the only canvas which is ever visible. No more than
  199. MAX_CANVAS_INDEX+1 canvases (including the screen) may be extant
  200. simultaneously.
  201.  
  202. Canvases may be manipulated by the following procedures:
  203.  
  204. typedef int canvasID;
  205. canvasID SRGP_createCanvas (int width, int height);
  206.  
  207.     An invisible canvas of the specified dimensions is created and its unique
  208.     index is returned. The new canvas' local-coordinate-system origin (0,0)
  209.     forms the lower-left corner. (w-1, h-1) forms the upper-right corner. The
  210.     pixels of a canvas are initially storing color value 0. Once a canvas is
  211.     created, it can not be resized. Upon return, the new canvas (and its
  212.     corresponding attribute group) are active. If a new canvas cannot be
  213.     created, 0 is returned.
  214. ------------------------------------------------------------------------------
  215. void SRGP_deleteCanvas (canvasID);
  216.  
  217.     No canvas may be deleted while it is active. Moreover, the screen canvas
  218.     may never be deleted.
  219. ------------------------------------------------------------------------------
  220. void SRGP_useCanvas (canvasID);
  221.  
  222.     The specified canvas becomes active. Primitives created subsequently are
  223.     drawn in this canvas, and attributes set subsequently modify this canvas'
  224.     attribute group.
  225.  
  226.  
  227.  
  228. *************** SECTION 3 >>>> Output
  229.  
  230.  
  231.  
  232.  
  233. *************** SECTION 3.1 >>>> color
  234.  
  235. SRGP maintains a lookup table (LUT) that maps color values (which are integers,
  236. used to index into the LUT) to actual colors. The number of entries available
  237. in the lookup table is based on the number of planes allocated for the
  238. application's use. The number of planes available can be inquired via:
  239.  
  240. int SRGP_inquireCanvasDepth (void);
  241.  
  242. The legal color values are numbers between (inclusive) 0 and 2^canvasdepth-1.
  243. The use of color values outside that range are "pegged" to 2^canvasdepth-1.
  244. All implementations support two colors that may be referenced using names
  245. instead of numbers: SRGP_WHITE and SRGP_BLACK (also known as COLOR_WHITE
  246. and COLOR_BLACK).
  247.  
  248. On color nodes, SRGP_WHITE is 1 and SRGP_BLACK is 0, and they are the only
  249. initialized entries in the LUT. One should note, however, that if the first two
  250. entries of the LUT are changed by the application, the names (SRGP_BLACK and
  251. SRGP_WHITE) are no longer meaningful.
  252.  
  253. On monochrome displays, the two symbols SRGP_BLACK and SRGP_WHITE are
  254. implementation-dependent constants. Moreover, the use of a color value greater
  255. than 1 is "pegged" to 1 on a monochrome display.
  256.  
  257. An application may load a contiguous portion of the LUT by creating three
  258. arrays (one for red, one for blue, one for green) of intensity values, each
  259. value being an unsigned 16-bit integer. Intensity value 0 represents that
  260. primary's not contributing at all to the actual color, and 2^16-1 (65,535)
  261. represents that primary contributing its full glory to the actual color. Note
  262. that this method for specifying colors is machine-independent; workstations
  263. supporting only C bits per intensity value will ignore all but the C most
  264. significant bits of each intensity value.
  265.  
  266. To load count entries of the LUT, starting with entry #start, create the three
  267. intensity value arrays and then call:
  268.  
  269. typedef unsigned short ush;
  270. void SRGP_loadColorTable (int start, int count, ush *r, ush *g, ush *b);
  271.  
  272. An easy way to store "common" colors is provided by SRGP. Common colors are
  273. those colors which have been given names (like "Purple",
  274. "MediumForestGreen", and "Orange").  (See COLORS.DOC.)  SRGP
  275. supports only the setting of one LUT entry at a time when using common colors:
  276.  
  277. void SRGP_loadCommonColor (int entry, char *colorname)
  278.  
  279.  
  280.  
  281. *************** SECTION 3.2 >>>> geometric data types
  282.  
  283. The following SRGP data types allow storage of geometric entities:
  284.  
  285. typedef struct {
  286.       int x, y;
  287. } point;
  288.  
  289. typedef struct {
  290.       point bottom_left, top_right;
  291. } rectangle;
  292.  
  293. Instances of these data types may be created using these routines:
  294.  
  295. point SRGP_defPoint (int x, int y);
  296. rectangle SRGP_defRectangle (int left_x, int bottom_y, int right_x, int top_y);
  297.  
  298.     
  299.  
  300.  
  301.  
  302. *************** SECTION 3.3 >>>> control of the pattern and font tables
  303.  
  304. Several of the SRGP attributes are patterns to be used for filling areas and 
  305. for drawing lines and frames. Two pattern tables are supported: one storing 
  306. bitmaps and one storing pixmaps. 
  307.  
  308. The bitmap pattern table is initialized in this way: Pattern 0 is all 
  309. background, and pattern 1 is all foreground. Patterns 1 through 38 are the 
  310. standard Macintosh patterns shown in Volume 1 of Chernicoff's Macintosh
  311. Revealed, and page I-474 of Inside Macintosh. Patterns 40 through 104 are 
  312. greyscale patterns increasing gradually in intensity from all background (40) 
  313. to all foreground (104).  All other entries in the bitmap pattern table have 
  314. random patterns initially. To see an array of tiles showing the default bitmap 
  315. pattern table, run the example program show_patterns. 
  316.  
  317. Only entry 0 in the pixmap pattern table is defined, and it is simply an 
  318. all-color-0 pattern. 
  319.  
  320. SRGP provides two methods for changing entries in the pattern table: 
  321.  
  322. **  You can have SRGP load one or more patterns from a file which stores 
  323.     ASCII-text pattern specifications you can create using a text editor or 
  324.     convenient bitmap-editor programs (if available). 
  325.  
  326. **  You can give SRGP a pattern specification in the form of an array of 
  327.     numbers. 
  328.  
  329. To load a bitmap pattern from a file, open the file and pass the stream to the 
  330. function: 
  331.  
  332. int SRGP_loadBitmapPatternsFromFile (FILE *stream);
  333.  
  334. The input may be composed of one or more pattern specifications ("specs"). 
  335. Each spec must occupy exactly two lines and must match this format: 
  336.  
  337. static char bitpat_Xy[] = {
  338.    0x??, 0x??, 0x??, 0x??, 0x??, 0x??, 0x??, 0x??};
  339.  
  340. where X is a non-negative integer specifying the index of the entry to be set, 
  341. y is any arbitrary garbage between the integer and the left square-brace, and 
  342. 0x?? is any arbitrary byte value represented in hexadecimal.  
  343.  
  344. As a convenience, any lines beginning with # are ignored, but these comment 
  345. lines must not interrupt a single two-line spec sequence. Blank unused lines 
  346. are not allowed anywhere in the file. 
  347.  
  348. The closing of the input stream must be performed by the caller. This function 
  349. returns 1 if any problems at all occurred; since its parser makes no attempt at
  350. error recovery, it is wise to check the return value. 
  351.  
  352. To load a pixmap pattern from a file, use this routine whose functionality is
  353. similar to that of the one for bitmap patterns: 
  354.  
  355. int SRGP_loadPixmapPatternsFromFile (FILE *stream);
  356.  
  357. Warning: the current Macintosh version does not support this. The input may be 
  358. composed of one or more pattern specifications, each matching this format: 
  359.  
  360. static int pixpat_Xy[] = {
  361.    ?, ?, ?, ?, ?, ?, ?, ?,
  362.    ?, ?, ?, ?, ?, ?, ?, ?,
  363.    ?, ?, ?, ?, ?, ?, ?, ?,
  364.    ?, ?, ?, ?, ?, ?, ?, ?,
  365.    ?, ?, ?, ?, ?, ?, ?, ?,
  366.    ?, ?, ?, ?, ?, ?, ?, ?,
  367.    ?, ?, ?, ?, ?, ?, ?, ?,
  368.    ?, ?, ?, ?, ?, ?, ?, ?};
  369.  
  370. In this specification, each ? represents a decimal integer color value. 
  371.  
  372. Applications generating the patterns at runtime can use these routines to set 
  373. one entry at a time:
  374.  
  375. void SRGP_loadBitmapPattern (int pattern_id, char *data);
  376. void SRGP_loadPixmapPattern (int pattern_id, int *data);
  377.  
  378.     The former routine expects an array of 8 characters; the latter an array of
  379.     64 integers.
  380.  
  381. Another attribute is the font to be used for text. SRGP provides a table of 
  382. fonts that may be used and modified by the application. Each entry is 
  383. identified by a unique font index (ranging from 0 to MAX_FONT_INDEX). 
  384. Initially, only entry #0 of the font table is defined. The application can 
  385. modify the table via: 
  386.  
  387. void SRGP_loadFont (int fontindex, char *name);
  388.  
  389.  
  390.  
  391.  
  392. *************** SECTION 3.4 >>>> control of attributes affecting output
  393.  
  394. These procedures allow control of the value of each attribute associated with 
  395. the currently-active canvas. 
  396.  
  397. typedef enum {WRITE_REPLACE, WRITE_XOR, WRITE_OR, WRITE_AND} writeModeType;
  398. void SRGP_setWriteMode (writeModeType);
  399.  
  400.     The write mode affects the writing of a pixel, the generation of a 
  401.     primitive, and the copying of a rectangular portion of a canvas. The 
  402.     default is WRITE_REPLACE. 
  403. ------------------------------------------------------------------------------
  404. void SRGP_setClipRectangle (rectangle);
  405.  
  406.     All subsequently-created primitives and subsequent pixel-copyings are
  407.     clipped to the specified rectangle. The default clipping rectangle is 
  408.     exactly the size of the associated canvas. It is illegal to set the 
  409.     clipping rectangle to a rectangle which does not lie completely within the 
  410.     boundaries of its associated canvas. 
  411. ------------------------------------------------------------------------------
  412. void SRGP_setFont (int font_index);
  413.  
  414.     The application chooses from a font by giving the index (ranging from 0 to 
  415.     MAX_FONT_INDEX) into the font table. The default is 0, the only entry in 
  416.     the font table which is initialized when SRGP is launched. 
  417. ------------------------------------------------------------------------------
  418. void SRGP_setMarkerSize (int width_in_pixels);
  419.  
  420.     This describes the dimensions of the imaginary square that circumscribes a 
  421.     marker's image. 
  422. ------------------------------------------------------------------------------
  423. typedef enum {MARKER_CIRCLE, MARKER_SQUARE, MARKER_X} markerStyleType;
  424. void SRGP_setMarkerStyle (markerStyleType);
  425.  
  426.     SRGP supports three different marker shapes, circle being the default. 
  427. ------------------------------------------------------------------------------
  428. typedef enum {CONTINUOUS, DASHED, DOTTED, DOT_DASHED} lineStyleType;
  429. void SRGP_setLineStyle (lineStyleType);
  430. void SRGP_setLineWidth (int width_in_pixels);
  431.  
  432.     The default line style is continuous, default line width is 1.
  433. ------------------------------------------------------------------------------
  434. void SRGP_setColor (int color_value);
  435.  
  436.     This sets the foreground (drawing) color to the color that is stored at the
  437.     given entry in the LUT; the default is 1. 
  438. ------------------------------------------------------------------------------
  439. void SRGP_setBackgroundColor (int color_value);
  440.  
  441.     Default is 0. The background color is used to color the pixels denoted by 0
  442.     values in opaque bitmap pattern fills. 
  443. ------------------------------------------------------------------------------
  444. void SRGP_setPlaneMask (int bitmask);
  445.  
  446.     (Warning: Currently the PC version does not support this!)
  447. ------------------------------------------------------------------------------
  448. typedef enum {
  449.   SOLID, BITMAP_PATTERN_OPAQUE, BITMAP_PATTERN_TRANSPARENT, PIXMAP_PATTERN}
  450.     drawStyle;
  451. void SRGP_setFillStyle (drawStyle);
  452. void SRGP_setPenStyle (drawStyle);
  453.  
  454.     Fill style affects filled primitives; pen style affects outlined (framed)
  455.     primitives or lines. Text is not affected by either of these attributes.
  456.     Default is SOLID.
  457. ------------------------------------------------------------------------------
  458. void SRGP_setFillBitmapPattern (int pattern_index);
  459. void SRGP_setFillPixmapPattern (int pattern_index);
  460. void SRGP_setPenBitmapPattern (int pattern_index);
  461. void SRGP_setPenPixmapPattern (int pattern_index);
  462.  
  463.     Denotes the entry in the appropriate pattern table which is to be used when
  464.     the fill or pen style is not SOLID.
  465.  
  466. The entire set of attributes may be set to a previously-stored group of values
  467. using the function described next. Later in this reference is described the
  468. function (SRGP_inquireAttributes) that allows inquiry of the current attribute
  469. group.
  470.  
  471. typedef struct ... attribute_group;   /* see srgppublic.h for details */
  472. void SRGP_setAttributes (attribute_group);
  473.  
  474.     The parameter's value should have been obtained from a previous call to
  475.     SRGP_inquireAttributes.
  476.  
  477.  
  478.  
  479. *************** SECTION 3.5 >>>> generation of primitives
  480.  
  481. The functions described in this section perform drawing in the currently active
  482. canvas. For each primitive generator described, the list of attributes 
  483. affecting its operation is presented. 
  484.  
  485. An ellipse is specified in terms of the rectangle within which it is inscribed.
  486. Polygons, rectangles, and ellipses may be generated as framed or filled. A 
  487. filled primitive is all-interior --- the frame is not displayed.      
  488.  
  489. void SRGP_point (point);
  490. void SRGP_pointCoord (int x, int y);
  491.  
  492.     Current write mode, foreground color, and plane mask apply. 
  493. ------------------------------------------------------------------------------
  494. void SRGP_marker (point)
  495. void SRGP_markerCoord (int x, int y)
  496.  
  497.     Current marker style, marker size, write mode, foreground color, and plane
  498.     mask apply. 
  499. ------------------------------------------------------------------------------
  500. void SRGP_line (point pt1, point pt2);
  501. void SRGP_lineCoord (int x1, int y1,  int x2, int y2);
  502.  
  503. void SRGP_rectangle (rectangle);
  504. void SRGP_rectanglePt (point lower_left, point upper_right);
  505. void SRGP_rectangleCoord (int left_x, int lower_y,  int right_x, int upper_y);
  506.  
  507.     Current write mode, plane mask, colors, line width, line style, and pen 
  508.     style apply. 
  509. ------------------------------------------------------------------------------
  510. void SRGP_polyPoint (int vert_count, point *vertices);
  511. void SRGP_polyMarker (int vert_count, point *vertices);
  512. void SRGP_polyLine (int vert_count, point *vertices);
  513. void SRGP_polygon (int vert_count, point *vertices);
  514.  
  515. void SRGP_polyPointCoord (int vert_count, int *x_coords, int *y_coords);
  516. void SRGP_polyMarkerCoord (int vert_count, int *x_coords, int *y_coords);
  517. void SRGP_polyLineCoord (int vert_count, int *x_coords, int *y_coords);
  518. void SRGP_polygonCoord (int vert_count, int *x_coords, int *y_coords);
  519.  
  520.     Current write mode, plane mask, colors, line width, line style, and pen 
  521.     style apply. SRGP_polygon(Coord) automatically connects the first and last 
  522.     vertices to form a closed polygon. Lists of vertices and coordinates are 
  523.     limited in size to MAX_POINTLIST_SIZE. 
  524. ------------------------------------------------------------------------------
  525. void SRGP_ellipse (rectangle bounds);
  526. void SRGP_ellipseArc (rectangle bounds, double startangle, double endangle);
  527.  
  528.     Current write mode, plane mask, colors, line width, line style, and pen 
  529.     style apply. An arc extends counterclockwise from the start angle to the 
  530.     end angle. Angles are in rectangular degrees and must lie between 0 and 
  531.     360, with 0 degrees being a horizontal ray extending towards positive 
  532.     infinity. 
  533. ------------------------------------------------------------------------------
  534. void SRGP_fillPolygon (int vert_count, point *vertices);
  535. void SRGP_fillPolygonCoord (int vert_count, int *x_coords, int *y_coords);
  536. void SRGP_fillEllipse (rectangle);
  537. void SRGP_fillEllipseArc (rectangle bounds, double startangle, double endangle);
  538. void SRGP_fillRectangle (rectangle);
  539. void SRGP_fillRectanglePt (point lower_left, point upper_right);
  540. void SRGP_fillRectangleCoord (int left_x, int lower_y, int right_x, int upper_y);
  541.  
  542.     Current write mode, plane mask, colors, and fill style apply. 
  543. ------------------------------------------------------------------------------
  544. void SRGP_text (point origin, char *str);
  545.  
  546.     Current write mode, plane mask, foreground color, and font apply. The 
  547.     origin marks the leftmost point to be affected by the text, and marks the 
  548.     horizontal baseline for the text, under which only the text's characters' 
  549.     descenders will appear. 
  550.  
  551.  
  552.  
  553. *************** SECTION 3.6 >>>> audio output
  554.  
  555.  
  556. void SRGP_beep (void);
  557.  
  558.     
  559.  
  560.  
  561.  
  562. *************** SECTION 4 >>>> The copyPixel Procedure
  563.  
  564. This procedure allows a portion of a canvas to be copied into another part of 
  565. itself or into another canvas. See the textbook for more information on this 
  566. powerful feature. 
  567.  
  568. void SRGP_copyPixel (canvasID source_canvas, rectangle source_rect, 
  569.                      point dest_corner);
  570.  
  571.     The copying operation is composed of two parts. First, a copy of a 
  572.     rectangular portion of a canvas is created. Then, the copy is placed 
  573.     somewhere within the currently-active canvas. (The currently-active canvas 
  574.     may or may not also be the canvas providing the source of the copy.) 
  575.  
  576.     dest_corner describes the lower-left corner of the destination rectangle 
  577.     (lying inside the currently-active canvas) having the same size as source_
  578.     rect. 
  579.  
  580.     Only the rectangular portion of source_rect which lies within the 
  581.     boundaries of the source canvas is copied. The placement operation is 
  582.     affected by the current clipping-rectangle and write-mode.  
  583.  
  584.  
  585.  
  586. *************** SECTION 5 >>>> Input
  587.  
  588. An application program obtains input from an operator by controlling a set of 
  589. logical input devices, each representing a unique input technique. Each device 
  590. may be placed in a number of different input modes, each representing a unique 
  591. type of interaction with the input device. 
  592.  
  593.  
  594.  
  595. *************** SECTION 5.1 >>>> properties of input devices
  596.  
  597. Each input device is described in terms of these information: a measure, a 
  598. trigger set, and a set of attributes. 
  599.  
  600. The measure of an input device is the value currently associated with the 
  601. device. 
  602.  
  603. The trigger of an an input device is the action which indicates a significant 
  604. moment associated with the device. 
  605.  
  606. The attributes of an input device are the parameters of the device which are 
  607. under application-control, primarily the echo characteristics. 
  608.  
  609. At any given time, each device is either active or inactive. The process of 
  610. activation places a device into an active state; the process of deactivation 
  611. places it into an inactive state. Zero or more devices may be simultaneously 
  612. active. 
  613.  
  614.  
  615.  
  616. *************** SECTION 5.2 >>>> input modes
  617.  
  618. There are three modes in which input devices operate. (Initially, each device 
  619. is inactive.) The modes' names are listed below, accompanied by a description: 
  620.  
  621.          INACTIVE   When device X is inactive, no events are posted concerning 
  622.                     it, and its measure is not available to the application. 
  623.  
  624.            SAMPLE   When device X is in Sample mode, it is active. The 
  625.                     application may call SRGP_sampleX to immediately obtain the
  626.                     measure of input device X. The firings of X-triggers do not
  627.                     have any effects. 
  628.  
  629.             EVENT   When device X is in Event mode, it is active. The firing of
  630.                     an X-trigger causes an input report (containing the measure
  631.                     of the device at the time of the firing) to be appended to 
  632.                     the input queue. 
  633.  
  634. The following function allows control of the input modes and echoing for all 
  635. input devices: 
  636.  
  637. typedef enum {NO_DEVICE, LOCATOR, KEYBOARD} inputDevice;
  638. typedef enum {INACTIVE, SAMPLE, EVENT} inputMode;
  639. void SRGP_setInputMode (inputDevice, inputMode);
  640.  
  641.     The specified input device is placed in the specified mode. Whenever device
  642.     X's mode is changed from Inactive to either Sample or Event, the device is 
  643.     activated: its measure is initialized (to a static default initial value, 
  644.     or to a value specified by the application while the device was inactive) 
  645.     and echoing begins. When X's mode is set to Event, queueing of the device's
  646.     event reports is enabled as well. When X's mode is changed from Event, all 
  647.     queued events for that device are discarded. 
  648.  
  649.     When X's mode is set to Inactive, the device is deactivated: trigger 
  650.     firings from the device are ignored and echoing is disabled. 
  651.  
  652.  
  653.  
  654. *************** SECTION 5.3 >>>> input devices
  655.  
  656. The SRGP input devices are described in this section. 
  657.  
  658.  
  659.  
  660.   LOCATOR   The measure of the Locator device incorporates a position expressed
  661.             in the coordinate system of the screen canvas, a chord giving the 
  662.             status of the mouse buttons, and the number of the button which 
  663.             most recently experienced a transition. The button-chord array is 
  664.             indexed using three constants: LEFT_BUTTON, MIDDLE_BUTTON, and 
  665.             RIGHT_BUTTON. 
  666.  
  667.             The button-mask attribute of this device determines which of the 
  668.             buttons are of interest when the device is active in Event mode: 
  669.             only buttons specified in this mask can trigger an event. 
  670.  
  671.                typedef enum {UP, DOWN} buttonStatus;
  672.                typedef struct {
  673.                   point position;
  674.                   buttonStatus button_chord[3];
  675.                   int button_of_last_transition;
  676.                } locator_measure;
  677.  
  678.             The "deluxe" version of the locator measure includes a chord 
  679.             giving the status of three primary modifier keys at the time of the
  680.             last button transition, and a timestamp structure. The modifier 
  681.             chord array is indexed via SHIFT, CONTROL, and META.  The timestamp
  682.             specifies the time at which the most recent change to the measure 
  683.             occurred --- i.e., successive sampling of a non-moving locator 
  684.             produces a "constant" timestamp. 
  685.  
  686.                typedef struct {
  687.                   int seconds;  /* duration since application launch */
  688.                   int ticks;    /* a tick is 1/60th second */
  689.                } srgp_timestamp;
  690.  
  691.                typedef struct {
  692.                   point position;
  693.                   buttonStatus button_chord[3];
  694.                   int button_of_last_transition;
  695.                   buttonStatus modifier_chord[3]; /*status at last transition*/
  696.                   srgp_timestamp timestamp;
  697.                } deluxe_locator_measure;
  698.  
  699.  
  700.  
  701.  KEYBOARD   The measure of this device is a character string, storing either a 
  702.             single ASCII character code or a sequence of printable characters. 
  703.  
  704.             The "deluxe" version of the measure includes the modifier chord 
  705.             and a timestamp: 
  706.  
  707.                typedef struct {
  708.                   char *buffer;   /* ptr to space allocated by application */
  709.                   int buffer_length;   /* set by application */
  710.                   buttonStatus modifier_chord[3];
  711.                   srgp_timestamp timestamp;
  712.                } deluxe_keyboard_measure;
  713.  
  714.             The processing-mode attribute of this device determines which of 
  715.             the two meanings is given to the measure of the device: 
  716.  
  717.              RAW:   When a key is hit, the measure stores a string of length 1 
  718.                     whose single element is the ASCII character code of the key
  719.                     hit (taking into account the status of the shift and 
  720.                     control modifier keys) and a trigger-firing occurs. The 
  721.                     modifier chord shows the status of the modifiers when the 
  722.                     key was hit. No echo occurs in RAW mode. 
  723.  
  724.             EDIT:   (the default)
  725.                     When a key representing a printable character is 
  726.                     hit and the string is not yet full, the character is 
  727.                     appended to the string. When the backspace key is hit, the 
  728.                     last character of the string is deleted. When return is 
  729.                     hit, an event is sent (representing the full value of the 
  730.                     string) and the measure is set to the null string. In EDIT 
  731.                     mode, the modifier chord is not maintained and should be 
  732.                     ignored. 
  733.  
  734.  
  735.  
  736. *************** SECTION 5.4 >>>> control of attributes
  737.  
  738. The following procedures set the attributes for input devices. Attributes may 
  739. be set at any time, regardless of whether the device is active or inactive. 
  740.  
  741. void SRGP_setLocatorButtonMask (int value);
  742.  
  743.     The value should be 0 or an OR combination of one or more of the following 
  744.     defined constants: LEFT_BUTTON_MASK, MIDDLE_BUTTON_MASK, and RIGHT_BUTTON_
  745.     MASK. Initially the value is LEFT_BUTTON_MASK: meaning only the left button
  746.     (which is the only button on a 1-button mouse) generates events. 
  747. ------------------------------------------------------------------------------
  748. SRGP_setLocatorEchoType (int value);  /* CURSOR, RUBBER_LINE, or RUBBER_RECT */
  749.  
  750.     An application can choose to have just the cursor, or to also have a 
  751.     rubber-primitive (anchored at a fixed point with the other end of the 
  752.     primitive following the cursor's movement). 
  753.  
  754. SRGP provides a cursor table whose 0th entry is initialized to an arrow; all 
  755. other entries are unusable until loaded.
  756.  
  757. void SRGP_loadCursorTable (int cursor_index, int shape);
  758.  
  759.     Legal cursor indices are numbers between 0 and MAX_CURSOR_INDEX, inclusive.
  760.     The shape may be one of the following: 1 for the "I-beam" 
  761.     text cursor, 2 for a cross, 3 for a "plus" cursor, and 4 for a watch 
  762.     icon. 
  763.  
  764. The attributes for the locator's echo are set via: 
  765.  
  766. void SRGP_setLocatorEchoCursorShape (int cursor_index);
  767. void SRGP_setLocatorEchoRubberAnchor (point position);
  768.  
  769.     
  770.  
  771. The keyboard's attributes are set via: 
  772.  
  773. typedef enum {EDIT, RAW} keyboardMode;
  774. void SRGP_setKeyboardProcessingMode (keyboardMode);
  775. void SRGP_setKeyboardEchoColor (int color_index);
  776. void SRGP_setKeyboardEchoFont (int font_index);
  777. void SRGP_setKeyboardEchoOrigin (point position);
  778.  
  779.     Keyboard echo attributes are only meaningful when the keyboard is active in
  780.     EDIT processing mode. Setting the keyboard's processing mode clears the 
  781.     keyboard's measure as a side-effect. 
  782.  
  783.  
  784.  
  785. *************** SECTION 5.5 >>>> control of measures
  786.  
  787. The measure of a device may be changed by the application at any time. If the 
  788. change is performed while the device is active, the measure immediately 
  789. changes, as does as echoing concerning the device. If it is done while the 
  790. device is inactive, the specified measure is used to initialize the device's 
  791. measure the next time it is activated. NOTE: the button-related fields of the 
  792. locator measure may not be changed by the application. 
  793.  
  794. void SRGP_setLocatorMeasure (point value);
  795. void SRGP_setKeyboardMeasure (char *value);
  796.  
  797.     
  798.  
  799.  
  800.  
  801. *************** SECTION 5.6 >>>> sample procedures
  802.  
  803. The involved input device must be in SAMPLE mode. Each function places in the 
  804. provided place the current measure of the corresponding device. Calls to these 
  805. routines are NOT traced. 
  806.  
  807. The SRGP_sampleKeyboard function copies the keyboard measure into the given 
  808. character-array buffer of size buffer_length. If the current keyboard measure 
  809. is longer than (bufferlength-1) bytes, it is truncated. Similarly, the 
  810. keyboard-measure structure sent to SRGP_sampleDeluxeKeyboard must have pre-set 
  811. values for its buffer and buffer_length fields. 
  812.  
  813. void SRGP_sampleLocator (locator_measure *measure);
  814. void SRGP_sampleKeyboard (char *buffer, int buffer_length);
  815. void SRGP_sampleDeluxeLocator (deluxe_locator_measure *measure);
  816. void SRGP_sampleDeluxeKeyboard (deluxe_keyboard_measure *measure);
  817.  
  818.     
  819.  
  820.  
  821.  
  822. *************** SECTION 5.7 >>>> event procedures
  823.  
  824. Calls to these functions are NOT traced. 
  825.  
  826. inputDevice SRGP_waitEvent (int maximum_wait_time);
  827.  
  828.     If, upon entry, the event queue is not empty, the procedure exits 
  829.     immediately, identifying the event report at the head of the queue and 
  830.     removing the report from the queue. Otherwise, the application enters a 
  831.     wait state, which is exited upon the first occurrence of a trigger-firing 
  832.     from any device which is currently in EVENT mode. The wait state never 
  833.     lasts for more than the number of ticks (1/60 seconds) given in the maximum
  834.     _wait_time parameter (which, when negative, represents infinity). An 
  835.     application can "poll" the queue (avoiding a wait state) by specifying 
  836.     "0" as the maximum wait time. 
  837.  
  838.     The return value identifies the device causing the event. The special value
  839.     NO_DEVICE is returned when the procedure exits due to timeout. 
  840.  
  841. When an application discovers that an input event (not a timeout) caused the 
  842. return of SRGP_waitEvent, it may obtain the data associated with the involved 
  843. event by using the appropriate "get" function, whose parameters and return 
  844. values mimic those of the sample functions: 
  845.  
  846. void SRGP_getLocator (locator_measure *measure);
  847. void SRGP_getKeyboard (char *measure, int buffer_length);
  848. void SRGP_getDeluxeLocator (deluxe_locator_measure *measure);
  849. void SRGP_getDeluxeKeyboard (deluxe_keyboard_measure *measure);
  850.  
  851.     
  852.  
  853.  
  854.  
  855. *************** SECTION 6 >>>> Inquiry
  856.  
  857. NOTE: Calls to these routines are NOT traced. 
  858.  
  859. void SRGP_inquireAttributes (attribute_group *group);
  860.  
  861.     The current states of all attributes are copied into the provided group 
  862.     structure. For information on the names of the fields in the structure, see
  863.     srgppublic.h. 
  864. ------------------------------------------------------------------------------
  865. canvasID SRGP_inquireActiveCanvas (void);
  866.  
  867.     This function allows inquiry of the ID of the currently-active canvas. 
  868. ------------------------------------------------------------------------------
  869. rectangle SRGP_inquireCanvasExtent (canvasID);
  870. void SRGP_inquireCanvasSize (canvasID, int *width, int *height);
  871.  
  872.     Two functions allowing inquiry of the size of a canvas. 
  873. ------------------------------------------------------------------------------
  874. int SRGP_inquireCanvasDepth (void);
  875.  
  876.     Returns the number of planes available in all canvases. 
  877. ------------------------------------------------------------------------------
  878. void SRGP_inquireTextExtent (char *str, int *width, int *ascent, int *descent);
  879.  
  880.     This procedure allows inquiry of the rectangular extent which would be 
  881.     covered by the output of the given character string with the current font 
  882.     attribute.  
  883.  
  884.  
  885.  
  886. *************** SECTION 7 >>>> Control of Table Sizes
  887.  
  888. The tables that store patterns, fonts, etc. have default sizes that in many
  889. cases are acceptable. You may, however, choose to reduce the size of a table to
  890. save memory or increase the size of a table if you need more entries. You may
  891. change the size of a table only before SRGP is initialized!
  892.  
  893. void SRGP_setMaxCanvasIndex (int i);
  894. void SRGP_setMaxPatternIndex (int i);
  895. void SRGP_setMaxCursorIndex (int i);
  896. void SRGP_setMaxFontIndex (int i);
  897. void SRGP_setMaxPointlistSize (int i);
  898.  
  899.     See srgp_sphigs.h for the defaults for these sizes. NOTE: Do not reduce the
  900.     size of the pattern table!
  901.     NOTE: These routines are currently unimplimented in the PC version.
  902.  
  903.  
  904.  
  905. *************** SECTION 8 >>>> Debugging and Optimization Aids
  906.  
  907. SRGP offers two features that aid the developer in debugging an application.
  908. Both of these features may be disabled or enabled by the programmer and even by
  909. the user at run-time, in order to optimize the execution.
  910.  
  911. The first feature is tracing. When enabled, each call to an SRGP routine
  912. (except a few input-related routines) produces a detailed message in a log
  913. file. A parameter to SRGP_begin() controls the initial state of tracing; calls 
  914. to SRGP_tracing can be used to control the state during runtime. Early test 
  915. runs of an application should always be performed with tracing enabled. For 
  916. more details on tracing, see Section 1. 
  917.  
  918. The second feature is parameter verification. All SRGP routines perform 
  919. verification of all parameters (except those that are pointers to an array or 
  920. structure) before they commence operation. All errors are fatal and produce a 
  921. crash with a detailed error message. Only when a program is fully debugged 
  922. should optimization efforts include disabling parameter verfication! You may
  923. permanently disable verification and tracing via: 
  924.  
  925. void SRGP_disableDebugAids (void);
  926.  
  927.  
  928.  
  929. *************** SECTION 9 >>>> Miscellaneous
  930.  
  931. Please see the README document for information regarding the use of TURBO C to
  932. create SRGP applications.
  933.  
  934.                                   --- FIN ---
  935.  
  936.